package cn.snowheart.boot.configuration;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.web.context.WebServerApplicationContext;
import org.springframework.stereotype.Component;

/**
 * 通过实现ApplicationRunner类，以在启动结束后，打印当前WebServer实现
 *
 * @author liuwanxiang
 * @version 2019/06/20
 */
@Component
public class WebServerRunner implements ApplicationRunner {

    private Logger logger = LoggerFactory.getLogger(WebServerRunner.class);

    @Autowired
    private WebServerApplicationContext context;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        logger.info("WebServer Impl: {}", context.getWebServer().getClass().getName());
    }
}
